<?php 
include('./fun.php');
$conn=my_sql($cfg);
$re=adm_login();
if($re['err']=='no_login'){die('<script>no_login()</script>');}
if($re['err']!='ok'){die('<hh><b>'.$re['err'].'</b></hh>');}
$adm=$re['adm'];
if($adm['power']!='adm'){err('抱歉，您没有查看的权限');}

$c=g('c');
$id=g('id');
if($id){
$sql='select * from '.$cfg['e'].'temps where id="'.$id.'"';
$l=db1($sql);

}

$s=['订单提交','退款'];

?>
<temp_list>
<l><text>模板标题</text>
<input placeholder="模板标题" value="<?php echo $l['title']?>" c="title" need="1">
</l>
<l><text>模板id</text>
<input placeholder="模板ID" value="<?php echo $l['temp_id']?>" c="temp_id" need="1">
</l>

<?php if($c=='temp'){?>
<l><text>数据</text>
<input placeholder="模板数据" value="<?php echo $l['data']?>" c="data" need="1">
</l>


<?php }?>

<l id="s"><text>分类</text>
<index>
<?php foreach($s as $v){
echo '<a class="m s '.($l['s']==$v?'select':'').'" onclick="select_s($(this))">'.$v.'</a>';
} ?>
</index>
<input value="<?php echo $l['s']?>" c="s">
</l>


<l><text>显示排序</text>
<input placeholder="显示排序" value="<?php echo ($l['o']?$l['o']:0)?>" c="o" type="number">
</l>

<l><a class="submit_bt" onclick="submit($(this))">提交</a></l>
</temp_list>


<script>
function select_s(o){
var val=o.html();
$('#s input').val(val);
$('#s a').removeClass('select');
o.addClass('select');
}

function submit(o){
var re=form_data($('temp_list input'));
if(re.can!=0){return;}
var data=re.data;
data.c='<?php echo $c;?>';
post('temp_edit',data,'<?php echo $l['id']?>',function(res){
    msg('修改成功');
    main_load();
    right_close();
});
}


</script>